package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.business.domain.MobileExhibitorsType;
import com.ruoyi.business.service.IMobileExhibitorsTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参展商分类Controller
 * 
 * @author ruoyi
 * @date 2024-06-13
 */
@RestController
@RequestMapping("/mobile/type")
public class MobileExhibitorsTypeController extends BaseController
{
    @Autowired
    private IMobileExhibitorsTypeService exhibitorsTypeService;

    /**
     * 查询参展商分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MobileExhibitorsType mobileExhibitorsType) {
        startPage();
        List<MobileExhibitorsType> list = exhibitorsTypeService.selectMobileExhibitorsTypeList(mobileExhibitorsType);
        return getDataTable(list);
    }

    /**
     * @Author liumaotong
     * @Description 参展商分类下拉菜单
     * @Date 2024/6/17
     * @Param [mobileExhibitorsType]
     * @return com.ruoyi.common.core.domain.AjaxResult
     */
    @RequestMapping("/listForSelect")
    public AjaxResult listForSelect(@RequestBody MobileExhibitorsType mobileExhibitorsType){
        return AjaxResult.success(exhibitorsTypeService.listForSelect(mobileExhibitorsType));
    }

    /**
     * 导出参展商分类列表
     */
    @Log(title = "参展商分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MobileExhibitorsType mobileExhibitorsType) {
        List<MobileExhibitorsType> list = exhibitorsTypeService.selectMobileExhibitorsTypeList(mobileExhibitorsType);
        ExcelUtil<MobileExhibitorsType> util = new ExcelUtil<MobileExhibitorsType>(MobileExhibitorsType.class);
        util.exportExcel(response, list, "参展商分类数据");
    }


    /**
     * 获取参展商分类详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(exhibitorsTypeService.selectMobileExhibitorsTypeById(id));
    }

    /**
     * 新增参展商分类
     */
    @Log(title = "参展商分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MobileExhibitorsType mobileExhibitorsType) {
        return toAjax(exhibitorsTypeService.insertMobileExhibitorsType(mobileExhibitorsType));
    }

    /**
     * 修改参展商分类
     */
    @Log(title = "参展商分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MobileExhibitorsType mobileExhibitorsType) {
        return toAjax(exhibitorsTypeService.updateMobileExhibitorsType(mobileExhibitorsType));
    }

    /**
     * 删除参展商分类
     */
    @Log(title = "参展商分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(exhibitorsTypeService.deleteMobileExhibitorsTypeByIds(ids));
    }
}
